<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" 
	xmlns:pe="http://primefaces.org/ui/extensions"
	template="/WEB-INF/templates/template.xhtml">
	
	<ui:define name="headIncludes">		
		<f:event listener="#{condicaoPagamentoBean.initializeForm(param.condicaoId)}" type="preRenderView"/>
		
		<style>
			.panel100 {
				width: 100px;
			}
			
		</style>
	</ui:define>

	<ui:define name="pageName">Detalhe de Condição de pagamento</ui:define>
	
	<ui:define name="buttons">
		<p:commandButton value="Editar" style="height:28px;" action="#{condicaoPagamentoBean.changeToEdit}" icon="ui-icon-pencil"/>
		<p:commandButton value="Excluir" style="height:28px;" onclick="popupConfirmDeleteDetail.show()" icon="ui-icon-trash"/>
		<p:commandButton value="Voltar" style="height:28px;" action="#{condicaoPagamentoBean.changeToList}" immediate="true" icon="ui-icon-arrowreturnthick-1-w"/>
	</ui:define>		
	
	<ui:define name="content">	
		<p:panel>
			<div>
				<p:messages id="messageFormCondicao" autoUpdate="true" closable="true"/>
				
					<h:panelGrid columns="2" style="padding:5px;" columnClasses="panel100">
						<h:outputText style="font-weight:bold;" value="Código" />
						<h:outputText style="font-weight:bold;" value="Condição de pagamento" />
						
						<h:outputText style="width:padding-right:20px;" value="#{condicaoPagamentoBean.currentCondicao.id}" />
						<h:outputText value="#{condicaoPagamentoBean.currentCondicao.condicaoPagamento}"/>
					</h:panelGrid>
				
					<h:panelGrid columns="1" style="padding:5px;" id="panelForma">
						<h:outputText style="font-weight:bold;" value="Forma de pagamento" />
						<h:outputText value="" />
						
						<h:outputText value="#{condicaoPagamentoBean.currentCondicao.formaPagamento.formaPagamento}"/>
					</h:panelGrid>
					
					<p:dataTable var="parcela" style="width:500px;padding-top:10px;"
						id="tableParcelas" value="#{condicaoPagamentoBean.currentCondicao.parcelas}"
						emptyMessage="Não há registros">  
				        <p:column headerText="Número" style="width:100px; text-align:center;"> 				         
				            <h:outputText value="#{parcela.numero}" />  
				        </p:column>  
				  
				        <p:column headerText="Dias" style="width:100px; text-align:center;">  
				            <h:outputText value="#{parcela.dia}"/>
				            <f:facet name="footer">
				            	<h:outputText value="Total" style="float:right;"/>
				            </f:facet>  
				        </p:column> 	
				        
				        <p:column headerText="Percentual" style="width:100px; text-align:center;">  
				            <h:outputText value="#{parcela.percentual}" >
				    			<f:convertNumber pattern="##0.00" />
				    		</h:outputText>  
				            <f:facet name="footer">
				            	<h:outputText value="#{condicaoPagamentoBean.currentCondicao.totalPercentual}">
				    				<f:convertNumber pattern="##0.00" />
				    			</h:outputText>   
				    			<h:outputText value="%"/>
				            </f:facet>
				        </p:column> 
			  		</p:dataTable>
				</div>
		</p:panel>
	</ui:define>
	
	<ui:define name="popups">
		<ui:include src="listFormaPagamento.xhtml"/>

		<p:dialog appendToBody="true" modal="true" closable="false" widgetVar="popupConfirmDeleteDetail"
			width="300" resizable="false" header="Confirmação de exclusão" height="90">
			<h:form>
				<div style="margin-top: 10px;">
					<h:outputText value="Confirma a exclusão do registro?"/>
				</div>
				<div align="right" style="margin-top: 15px; margin-bottom: 15px;">
					<p:commandButton value="Excluir" actionListener="#{condicaoPagamentoBean.removeFromDetail}" oncomplete="popupConfirmDeleteDetail.hide()" icon="ui-icon-trash"/>
					<p:commandButton value="Cancelar" onclick="popupConfirmDeleteDetail.hide()" icon="ui-icon-cancel"/>
				</div>		
			</h:form>			
		</p:dialog>
		
		<p:dialog id="completeDialogDelete" header="Confirmação de exclusão" closable="false"
			widgetVar="completeDeletePopup" width="300" resizable="false">
			<h:form>
			<div style="margin-top: 10px;">Excluído com sucesso!</div>
			
			<div align="right" style="margin-top: 15px; margin-bottom: 15px;" > 
				<p:commandButton id="complete" value="Fechar" oncomplete="completeDeletePopup.hide()" icon="ui-icon-close" 
					action="#{condicaoPagamentoBean.changeToList}" />
			</div>
			</h:form>
		</p:dialog>
	</ui:define>
</ui:composition>